package com.fast.cron.db.dao;

import com.fast.cron.db.entry.ScheduleJob;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author: Leo Jie
 * @date: 2018-10-04 19:52
 * @version: v1.0
 */
public interface ScheduleJobDao {
    /**
     * add schedule job
     *
     * @param scheduleJob schedule obj that to add
     * @return rows number
     * @throws SQLException the error when execute sql
     */
    long addJobToSchedule(ScheduleJob scheduleJob) throws SQLException;

    /**
     * update cron of job
     *
     * @param scheduleJobId id of job
     * @param jobCron       new cron
     * @return rows number
     * @throws SQLException the error when execute sql
     */
    int updateCronOfScheduleJob(int scheduleJobId, String jobCron) throws SQLException;

    /**
     * remove schedule job,change status to -2 of job
     *
     * @param scheduleJobId id of job
     * @return rows number
     * @throws SQLException the error when execute sql
     */
    int removeCronOfScheduleJob(int scheduleJobId) throws SQLException;

    /**
     * list schedule jobs
     *
     * @return list result of jobs
     * @throws SQLException the error when execute sql
     */
    List<Map<String, Object>> listScheduleJob() throws SQLException;
}
